package com.bss.model;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.bss.AbstractNamedEntity;

@Entity
@Table(name = "materialset")
public class MaterialSet extends AbstractNamedEntity {

	private static final long serialVersionUID = 8633357087668449861L;

	private int id;

	private String name;

	private int deposit;

	private boolean editable;

	private List<MaterialSetMapping> materialSetMappings = new ArrayList<MaterialSetMapping>(
			0);

	private Set<Admission> admissions = new HashSet<Admission>(0);

	public MaterialSet() {
	}

	public MaterialSet(final int id) {
		this.id = id;
	}

	public MaterialSet(final int id, final String name) {
		this.id = id;
		this.name = name;
	}

	@Id
	@Column(name = "id", unique = true, nullable = false)
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Integer getId() {
		return this.id;
	}

	@Override
	public void setId(final int id) {
		this.id = id;
	}

	@Column(name = "name", length = 25)
	public String getName() {
		return this.name;
	}

	public void setName(final String name) {
		this.name = name;
	}

	public void setDeposit(final int deposit) {
		this.deposit = deposit;
	}

	@Column(name = "deposit")
	public int getDeposit() {
		return this.deposit;
	}

	public void setMaterialSetMappings(
			final List<MaterialSetMapping> materialSetMappings) {
		this.materialSetMappings = materialSetMappings;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "materialSet")
	public List<MaterialSetMapping> getMaterialSetMappings() {
		return this.materialSetMappings;
	}

	public void setEditable(final boolean editable) {
		this.editable = editable;
	}

	@Column(name = "editable")
	public boolean isEditable() {
		return this.editable;
	}

	public void setAdmissions(final Set<Admission> admissions) {
		this.admissions = admissions;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "materialSet")
	public Set<Admission> getAdmissions() {
		return this.admissions;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "date", length = 19)
	public Date getDate() {
		return this.date;
	}
}
